﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DbSetupHelper.Plugin.ScriptPackage;
using System.Reflection;

namespace DbSetupHelper.ScriptExample
{
    public class ScriptPackage : IScriptPackage
    {
        #region IScriptPackage Members

        /// <summary>
        /// Fetches the control XML stream.
        /// </summary>
        /// <returns>A stream of the XML script.</returns>
        public Stream FetchControlXmlStream()
        {
            return Assembly.GetExecutingAssembly()
                .GetManifestResourceStream("DbSetupHelper.ScriptExample.Control.xml");
        }

        /// <summary>
        /// Fetches the SQL script.
        /// </summary>
        /// <param name="scriptName">Name of the script.</param>
        /// <returns>A stream of the SQL script.</returns>
        public Stream FetchSqlScript(string scriptName)
        {
            return Assembly.GetExecutingAssembly()
                .GetManifestResourceStream("DbSetupHelper.ScriptExample.Scripts." + scriptName);
        }

        #endregion
    }
}
